<template>
  <div>
    <m-header></m-header>
    <div class="person-wrap">
      <div class="myHeader">
        <img :src="userInfo.avatar" alt="" class="avatar" />
        <div class="name">{{ userInfo.username }}</div>
        <!-- <Button class="edit" type="primary">编辑</Button> -->
      </div>
      <div class="content">
        <div class="left">
          <div
            @click="changeRouter(item.path)"
            v-for="item in doctor"
            :key="item.id"
          >
            <router-link
              :to="item.path"
              :class="item.path == currentRouter ? 'active' : 'navItem'"
              ><span :class="item.icon"></span>
              <p>{{ item.title }}</p></router-link
            >
          </div>
        </div>
        <div class="right">
          <router-view></router-view>
        </div>
      </div>
    </div>
    <bottom></bottom>
  </div>
</template>

<script>
import mHeader from "@/components/header.vue";
import bottom from "@/components/bottom.vue";
import { getSession } from "../../utils";

export default {
  components: {
    mHeader,
    bottom,
  },
  data() {
    return {
      userInfo: {},
      user: [],
      currentRouter: "/personInfo",
      doctor: [
        {
          title: "个人信息",
          path: "/personInfo",
          icon: "iconfont icon-gerenzhongxin",
        },
        {
          title: "发表文章",
          path: "/postArtical",
          icon: "iconfont icon-16",
        },
        {
          title: "发表视频",
          path: "/postVideo",
          icon: "iconfont icon-video",
        },
        {
          title: "直播设置",
          path: "/liveSet",
          icon: "iconfont icon-zhibo",
        },
      ],
    };
  },
  created() {
    let userInfo = getSession("userInfo");
    this.userInfo = userInfo;
  },
  methods: {
    changeRouter(path) {
      console.log(path);
      this.currentRouter = path;
    },
  },
};
</script>

<style lang='less' scoped>
.person-wrap {
  margin: 0 auto;
  width: 880px;
}
.myHeader {
  margin-top: 15px;
  height: 130px;
  width: 100%;
  background-color: #fff;
  display: flex;
  align-items: center;
  position: relative;
  img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0px 30px 0px 60px;
  }
  .edit {
    position: absolute;
    right: 50px;
  }
}
.content {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
}
.left {
  width: 25%;
  height: 600px;
  background-color: #fff;
  .navItem {
    display: flex;
    justify-content: center;
    line-height: 50px;
    text-align: center;
    span {
      margin-right: 20px;
    }
  }
  .active {
    background-color: #2d8cf0;
    display: flex;
    justify-content: center;
    line-height: 50px;
    text-align: center;
    color: #fff;
    span {
      margin-right: 20px;
      color: #fff;
    }
    p {
      color: #fff;
    }
  }
}
.right {
  width: 73%;
  min-height: 600px;
  background-color: #fff;
}
</style>
